package com.lv.LvAttachmentComboOfTourismModel.dao;
import com.aqgj.util.BaseDaoImpl;
import com.lv.LvAttachmentComboOfTourismModel.bean.LvAttachmentComboOfTourismModel;
import org.springframework.stereotype.Repository;
/**
 * <p>
 *
 * </p>
 *
 * @ClassName LvAttachmentComboOfTourismModelDao
 * @JDK 1.5
 * @author
 * @date
 */
@Repository("LvAttachmentComboOfTourismModelDao")
public class LvAttachmentComboOfTourismModelDao extends BaseDaoImpl<LvAttachmentComboOfTourismModel> {
    /**
     * 修改
     * @param lvAttachmentComboOfTourismModel 实体bean
     * @return 0.失败1.成功
     */
    public String update(LvAttachmentComboOfTourismModel lvAttachmentComboOfTourismModel) {
        this.getHibernateTemplate().saveOrUpdate(lvAttachmentComboOfTourismModel);
        if (lvAttachmentComboOfTourismModel.getId() != null) {
            return "1";
        }
        return "0";
    }

    /**
     * 删除模板附件
     * @param id 附件id
     * @param modelId 模板id
     * @return
     */
    public String delete(String id, String modelId) {
        String sql = "delete from lv_attachment_combo_of_tourism_model where 1=1";
        if (id != null) {
            sql += " and id='" + id + "'";
        }
        if (modelId != null) {
            sql += " and fk_tourism_model_id='" + modelId + "'";
        }
        if (this.currentSession().createNativeQuery(sql).executeUpdate() >= 0) {
            return "1";
        }
        return "0";
    }
}